<template>
  <el-container class="admin">
    <el-header class="header">
      <span class="title">Restaurant Admin</span>
      <el-button size="small" type="danger" @click="logout">退出</el-button>
    </el-header>

    <el-container>
      <el-aside width="200px" class="aside">
        <el-menu
          router
          :default-active="$route.path"
          background-color="#304156"
          text-color="#bfcbd9"
          active-text-color="#409EFF"
        >
          <el-menu-item index="/admin/stores">
            <el-icon><Shop /></el-icon>
            <span>门店管理</span>
          </el-menu-item>
          <el-menu-item index="/admin/waiters">
            <el-icon><User /></el-icon>
            <span>员工账号</span>
          </el-menu-item>
          <el-menu-item index="/admin/printers">
            <el-icon><Printer /></el-icon>
            <span>打印机</span>
          </el-menu-item>
          <el-menu-item index="/admin/pay">
            <el-icon><Money /></el-icon>
            <span>支付配置</span>
          </el-menu-item>
        </el-menu>
      </el-aside>

      <el-main class="main">
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'
import { Shop, User, Printer, Money } from '@element-plus/icons-vue'
const router = useRouter()
function logout() {
  localStorage.clear()
  router.replace('/login')
}
</script>

<style scoped>
.admin { height: 100vh; }
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  padding: 0 16px;
}
.aside { background: #304156; }
.main  { padding: 16px; background: #f5f5f5; }
</style>